package com.bg8loo.amateur.dao;

import com.bg8loo.amateur.pojo.Title;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.ArrayList;

@Mapper
public interface TitleDao {
    //查询题库数据
    @Select("select id, context, Ase, Bse, Cse, Dse,grade from ${type}")
    ArrayList<Title> getAllTitle(String type);

    //添加题目方法
    @Insert("insert into  ${type}(context, Ase, Bse, Cse, Dse,grade) values( #{context},#{Ase},#{Bse},#{Cse},#{Dse},#{grade})")
    void addTitle(String type,String context,String Ase,String Bse,String Cse,String Dse,String grade);

    //查询题库数据通过编号
    @Select("select id, context, Ase, Bse, Cse, Dse,grade from ${type} where grade=#{grade}")
    Title getTitleByGrade(String type,String grade );

    //改变配置单评论的状态
    @Update("update ${type} set picture=#{picture} where id= #{id}")
    void updataPictureById(String type,String picture,int id);


    //改变配置单评论的状态
    @Update("update ${type} set picture=#{picture} where grade= #{grade}")
    boolean updataPictureByGrade(String type,String grade,String picture);

    @Select("SELECT * FROM roea ORDER BY RAND() LIMIT 10;")
    ArrayList<Title> selectRoeaRand10();

    @Select("SELECT * FROM roeb ORDER BY RAND() LIMIT 10;")
    ArrayList<Title> selectRoebRand10();


    ArrayList<Title> selectRoeaExam30();

    ArrayList<Title> selectRoebExam50();

    ArrayList<Title> selectRoecExam80();
}
